package com.bjwl.web.contrlller.branchstore;

import com.bjwl.pojo.Bsadmin;
import com.bjwl.pojo.CardDenomination;
import com.bjwl.pojo.vo.BasicQueryVo;
import com.bjwl.service.CardDenominationService;
import com.bjwl.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * @Author: dzx
 * @Date:Create：in 2020/5/8 14:02
 * @Description:
 * @Modified By：
 * @Version: 1.0
 */
@Controller
@RequestMapping("/bsCardDenominations")
public class CardDenominationControllerabc {

    @Autowired
    private CardDenominationService cardDenominationService;

    @RequestMapping("/findAllCardDenomination")
    public String findAllCardDenomination(BasicQueryVo vo, Model model){
        PageBean<CardDenomination> pageBean = cardDenominationService.findAllCardDenomination(vo);
        model.addAttribute("pageBean",pageBean);
        return "branch_oa/cardtype-list";
    }

    @RequestMapping("/addCardDenomination")
    public @ResponseBody
    boolean addCardDenomination(@RequestBody CardDenomination cardDenomination , HttpSession httpSession){
        Bsadmin bsadmin = (Bsadmin) httpSession.getAttribute("bsadmin1");
        cardDenomination.setBsid(bsadmin.getBsid());
        return cardDenominationService.addCardDenomination(cardDenomination);
    }

    /**
     * 修改前回显
     * @param
     * @return
     */
    @RequestMapping("/updateCardDenominationS")
    public String updateCardDenominationS(Integer id, Model model){
        model.addAttribute("CardDenomination",cardDenominationService.editStart(id));
        return "branch_oa/cardtype-edit";
    }

    /**
     * 修改
     * @param
     * @return
     */
    @RequestMapping("/updateCardDenomination")
    public @ResponseBody
    boolean updateCardDenomination(@RequestBody CardDenomination cardDenomination){
        cardDenominationService.updateCardDenomination(cardDenomination);
        return true;
    }

    /**
     * 修改
     * @param
     * @return
     */
    @RequestMapping("/deleteCardDenomination")
    public @ResponseBody
    boolean deleteCardDenomination(@RequestBody Integer id){

        return cardDenominationService.deleteCardDenomination(id);
    }

}
